home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK1.toast / Development Kits (Disc 1) / QuickDraw GX / Programming Stuff / Sample Code / Printing Samples / Applications… / QuickDraw GX Aware Sample ƒ / Simple Sample ƒ / Simple Sample.h < prev    next >
Encoding:
Text File  |  1996-03-20  |  5.5 KB  |  177 lines  |  [TEXT/MMCC]

  1. /*********************************************************************
  2.  
  3.     Simple Sample.h
  4.     
  5.     This is the header file for the QuickDraw GX unaware sample,
  6.     "Simple Sample."
  7.     
  8.     Additional info can be found in the related develop #19 article,
  9.     "Adding QuickDraw GX Printing to QuickDraw Applications."
  10.  
  11.     Dave Hersey, Apple Developer Technical Support.
  12.     
  13.     ——————— Edit Trail ———————
  14.     
  15.     spawned:                                        1/22/94  - dmh
  16.     cleaned up for 2nd draft of develop article:    3/10/94  - dmh
  17.     cleaned up for final:                            4/14/94  - dmh
  18.     universalized:                                    8/24/94  - dmh
  19.     
  20. *********************************************************************/
  21.  
  22. //#include <stdio.h>
  23. #include <AppleEvents.h>
  24. #include <Desk.h>
  25. #include <Events.h>
  26. #include <Files.h>
  27. #include <Fonts.h>
  28. #include <GestaltEqu.h>
  29. #include <Memory.h>
  30. #include <Packages.h>
  31. #include <Printing.h>
  32. #include <Quickdraw.h>
  33. #include <Resources.h>
  34. #include <StandardFile.h>
  35. #include <ToolUtils.h>
  36. #include <Types.h>
  37. #include <Windows.h>
  38. #include <GXExceptions.h>            // <-- Note that this does not use QuickDraw GX.
  39.  
  40.  
  41. #define    kOSEvent                    app4Evt    /* Event used by MultiFinder                    */
  42. #define    kSuspendResumeMessage        1        /* High byte of suspend/resume event message    */
  43. #define    kResumeMask                    1        /* Bit of message field for resume vs. suspend    */
  44.  
  45. #define        r_About                128            /* Our app's "About…" alert ID.                    */
  46. #define        r_BadConfig            130            /* Our app's "Bad configuration…" alert ID.        */
  47. #define        r_documentPict        128            /* Our PICT's resource ID.                        */
  48. #define        r_documentBitmap    128            /* Our ICON's resource ID.                        */
  49.  
  50. #define        kMyDocCreator        'SSam'        /* Our app's creator.                            */
  51. #define        kMyDocType            'aDoc'        /* Our document file type.                        */
  52. #define        kMyPageCountType    'Pgs?'        /* Our page count resource type.                */
  53. #define        kMyPageCountID        2000        /* Our page count resource ID.                    */
  54. #define        kMyPrintRecType        'THPR'        /* Our print record resource type.                */
  55. #define        kMyPrintRecID        1000        /* Our print record resource ID.                */
  56.  
  57. #define        kDefaultTitle        ((char *) "\pUntitled Document")
  58.  
  59. // Various PicComments:
  60.  
  61. #define        PostScriptBegin        190
  62. #define        PostScriptEnd        191
  63. #define        PostScriptHandle    192
  64.  
  65.  
  66. /*
  67.     MyDocumentRec - This structure contains information that we store
  68.     about each document we open or create.  We store a handle to one
  69.     of these beasties in each window's refCon field.  Note that the
  70.     MyDocumentRec data type in this example is simplified to handle a
  71.     maximum of 20 pages.
  72. */
  73.  
  74. #define kMaxPages    20
  75.  
  76. typedef struct MyDocumentRec {
  77.         THPrint            documentPrintHdl;            // Print Record bound to this document.
  78.         long            numPages;                    // Number of pages in this document.
  79.         long            curPage;                    // The current page that we're looking at.
  80.         FSSpec            documentFSSpec;                // The file specification for this document.
  81.         Str31            documentTitle;                // The title of this document (such
  82.                                                     // as "Untitled").
  83.         WindowPtr        documentWindow;                // The window for this document.
  84. } MyDocumentRec, *MyDocumentPtr;
  85.  
  86.  
  87. // globals from main.c:
  88.  
  89. extern short                 gAppResRefNum;
  90. extern Rect                 gWindowRect;
  91. extern Boolean                gQuitAfterPrinting, gQuitting, gSystemSevenIsPresent;
  92. extern long                    gSleep;
  93.  
  94.                     //  Prototypes: //
  95.  
  96. // main.c:
  97.  
  98. void            MyInitialize(void);
  99. void            MyCheckConfig(void);
  100. void            main(void);
  101.  
  102. // events.c
  103.  
  104. void            MyEventLoop(void);
  105. void            MyDoEvent(EventRecord *theEvent);
  106. void            MyDoAEInstallation(void);
  107. pascal OSErr    MyHandleOAPP(AppleEvent *theAppleEvent, AppleEvent *reply, long myRefCon);
  108. pascal OSErr    MyHandleQUIT(AppleEvent *theAppleEvent, AppleEvent *reply, long myRefCon);
  109. pascal OSErr    MyHandleODOC(AppleEvent *theAppleEvent, AppleEvent *reply, long myRefCon);
  110. pascal OSErr    MyHandlePDOC(AppleEvent *theAppleEvent, AppleEvent *reply, long myRefCon);
  111. OSErr            MyCheckAEParams(AppleEvent *theAppleEvent);
  112.  
  113. // file.c
  114.  
  115. OSErr            MyLoadDocument(MyDocumentPtr whichDocument);
  116. OSErr            MyFSLoadDocument(MyDocumentPtr destDocument, FSSpec *docFSSpec, Boolean forPrinting);
  117. Boolean            MyIsWindowAlreadyOpen(FSSpec *whichFSSpec);
  118. OSErr            MySaveDocument(MyDocumentPtr myDocument, Boolean doingSaveAs);
  119. OSErr            MySavePageCount(MyDocumentPtr whichDocument, short resRefNum);
  120. long            MyLoadPageCount(short resRefNum);
  121. OSErr            MySavePrintInfo(MyDocumentPtr whichDocument, short resRefNum);
  122. OSErr            MyLoadPrintInfo(MyDocumentPtr whichDocument, short resRefNum);
  123.  
  124. // menus & windows.c:
  125.  
  126. OSErr            MyCreateDocument(char *title, MyDocumentPtr *createdDocument);
  127. void            MyDisposeDocument(MyDocumentPtr whichDocument);
  128. OSErr            MyInsertPage(MyDocumentPtr whichDocument, long *whichPage);
  129. void            MyDisposePage(MyDocumentPtr whichDocument, long whichPage);
  130. void            MyUpdateWindow(WindowPtr whichWindow);
  131. void            MyDrawContents(WindowPtr whichWindow);
  132. void            MyDrawPicComments(void);
  133. void            MySendPostScript(Str255 thePostScript);
  134. void            MyAdjustMenus(void);
  135. void            MyDoMenuCommand(long menuResult);
  136. MyDocumentPtr    MyGetDocPtr(WindowPtr whichWindow);
  137.  
  138. // printing.c:
  139.  
  140. OSErr            MyPrintDocument(MyDocumentPtr whichDocument);
  141. OSErr            MyPrintLoop(MyDocumentPtr whichDocument);
  142. Boolean            MyDoPageSetup(MyDocumentPtr whichDocument);
  143. void            MyRepaginateDoc(MyDocumentPtr whichDocument);
  144.  
  145.  
  146. // resource & menu item equates:
  147.  
  148. #define rMenuBar        128
  149. #define mApple            128
  150. #define     iAbout                1
  151.  
  152. #define mFile            129
  153. #define     iNew                1
  154. #define     iOpen                2
  155. #define     iClose                3
  156. #define     iSave                4
  157. #define     iSaveAs            5
  158. #define     iPageSetup            7
  159. #define     iPrint                8
  160. #define     iQuit                   10
  161.  
  162. #define mEdit            130
  163. #define     iUndo                1
  164. #define     iCut                3
  165. #define     iCopy                4
  166. #define     iPaste                5
  167. #define     iClear                6
  168.  
  169. #define mDocument        131
  170. #define     iInsertPage        1
  171. #define     iDeletePage        2
  172. #define     iAheadPage            4
  173. #define     iBackPage            5
  174.  
  175.  
  176.  
  177.